package cn;

import java.io.File;
import java.util.Locale;

/**
 * description:
 * author:zcx
 * lenovo
 * 时间：2022.01.17.20.27
 */
public class FileJob1 {
    public static int sum=0;
    public static int png=0;
    public static int jpg=0;
    public static void main(String[] args) {
    var d=new File(System.getProperty(""));
     count(d);
        System.out.println("java文件有"+sum);
        System.out.println("png文件有"+png);
        System.out.println("jpg文件有"+jpg);
    }
    public static void count(String dir){
        count(new File(dir));
    }
    public static void  count(File dir){
        for(File t:dir.listFiles()){
            if(t.isDirectory()){
                count(t);
            }else if(t.getName().toLowerCase(Locale.ROOT).endsWith(".java")) {
                ++sum;
            }else if(t.getName().toLowerCase(Locale.ROOT).endsWith(".png")){
                ++png;
            }else if(t.getName().toLowerCase(Locale.ROOT).endsWith(".jpg")){
                ++jpg;
            }
        }
    }
}
